package sg.nus.iss.vmcs.gui.elements;

import java.awt.Component;
import java.awt.FlowLayout;
import java.awt.Label;
import java.awt.Panel;

import sg.nus.iss.vmcs.utils.Constant;

/**
 * Warning Display used in the Maintenance Panel<br><br>
 * Modifications:
 * <li>27/12/2010 - Philip - Tidied up class and removed global imports</li>
 * <li>28/12/2010 - Philip - Introduced state pattern</li>
 * <br>
 * <br>
 * @author Olivo Miotto
 * @author Philip Chew
 */
public class WarningDisplay extends Panel implements VariableDisplayStateContext {

    /** Generated Serial ID */
	private static final long 	serialVersionUID = 3040881056479422917L;
	
	/** Label to Display Data */
    private Label lb;
    
    /** The current display state */
    private VariableDisplayState vds;

    /**
     * Creates a new instance of the warning display
     * @param label The text to be displayed
     */
    public WarningDisplay (String label) {
        lb = new Label(label);
        lb.setFont(Constant.LABEL_FONT);
        lb.setAlignment(Label.CENTER);
      
        this.setLayout(new FlowLayout());        
        this.add(lb);
    }

	/* 
	 * Returns label to be set
	 */
	@Override
	public Component getDisplayComponent() {
		return lb;
	}

	/* 
	 * Sets the Variable Display State
	 */
	@Override
	public void setVariableDisplayState(VariableDisplayState vds) {
		this.vds = vds;
		
	}

	/**
	 * Sets the Display
	 */
	@Override
	public void setDisplay() {
		vds.setDisplayComponent(this);
	}
}